﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls;

namespace DLL.Column
{
	/// <summary>
	/// 用户组视图控制类
	/// </summary>
	/// <![CDATA[2014-8-7 17:52:59]]>
	public class View : DLL.ShowLayer.FormView
	{
		private Component clsthisComp;

		#region 添加、修改
		private TextBox tbColumnName = new TextBox();		// 栏目名称
		private DropDownList ddlParentColumn = new DropDownList();		// 上级栏目
		private TextBox tbOrder = new TextBox();		// 栏目显示顺序
		private DropDownList ddlLink = new DropDownList();		// 栏目地址
		#endregion 添加、修改

		#region 查询
		private TextBox tbQueryColumnName = new TextBox();		// 栏目名称
		private DropDownList ddlQueryParentColumn = new DropDownList();		// 上级栏目
		#endregion 查询

		#region 浏览

		#endregion 浏览

		public View(System.Web.UI.Page page)
			: base(page)
		{
			clsthisComp = new Component(page);

			clsComp = clsthisComp;

			clsControls.ColumnWithNoParentOrder(ddlParentColumn);
			clsControls.SetLinkDropDownList(ddlLink);
			listAddEdit.Add(new TonyNet4V1.Structs.TitleControlEntity("栏目名称", "TextBox", tbColumnName, "string", "strColumnName"));
			listAddEdit.Add(new TonyNet4V1.Structs.TitleControlEntity("上级栏目", "DropDownList", ddlParentColumn, "int", "nParentID"));
			listAddEdit.Add(new TonyNet4V1.Structs.TitleControlEntity("顺序", "TextBox", tbOrder, "int", "nOrder"));
			listAddEdit.Add(new TonyNet4V1.Structs.TitleControlEntity("地址", "DropDownList", ddlLink, "string", "strLink"));

			clsControls.ColumnWithAllNoParentOrder(ddlQueryParentColumn);
			listQuery.Add(new TonyNet4V1.Structs.TitleControlEntity("栏目名称", "TextBox", tbQueryColumnName, "string", "strColumnName"));
			listQuery.Add(new TonyNet4V1.Structs.TitleControlEntity("上级栏目", "DropDownList", ddlQueryParentColumn, "int", "nParentColumnID"));
		}

		#region 类型转换

		protected override TonyNet4V1.EntityBase GetEntity()
		{
			return new Entity();
		}

		protected override TonyNet4V1.QueryEntityBase GetQuery()
		{
			return new QueryEntity();
		}

		protected override TonyNet4V1.ComponentBase GetComponent()
		{
			return clsthisComp;
		}

		#endregion 类型转换

		public override bool QueryDefault(GridView gv)
		{
			//return base.QueryDefault(gv);
			List<Entity> list = new List<Entity>();

			list = clsthisComp.QueryAllOrder();
			clsthisComp.AddGradeInName(list, "|", "--");
			gv.DataSource = list;
			gv.DataKeyNames = new string[] { "ID" };
			gv.DataBind();

			return true;
		}
	}
}
